"use client"
import {login} from "@/actions";
import {useFormState} from "react-dom";

export default function LoginForm() {
    const [state, formAction] = useFormState<any, FormData>(login, undefined)
    return (
        <form action={formAction} className="flex flex-col min-w-sm gap-4">
            <input type="text" name="username" required placeholder="Username" className="border-1"/>
            <input type="password" name="password" required placeholder="Password" className="border-1"/>
            <button className="border">Login</button>
            {state?.error && <p>{state.error}</p>}
        </form>
    )
}